const { REFUSED } = require('dns');
const http = require('http');

async function getMeter(){
    // 发送 GET 请求
    const options = {
        hostname: '192.168.31.11',
        port: 5000,
        path: '/application_info/false',
        method: 'GET'
    };

    const req = http.request(options, function(res) {
    let data = '';

    res.on('data', function(chunk) {
        data += chunk;
    });

    res.on('end', function() {
        let meter = JSON.parse(data)
        console.log(JSON.stringify(meter));
        return JSON.stringify(meter)
    });
    });

    req.on('error', function(err) {
    console.log(err);
    });

    req.end();
}

module.exports = {getMeter}